package com.ryoma.Utils;

import net.sf.json.JSONObject;

import java.util.Iterator;
import java.util.Map;

public  class JsonUtils {

    /**
     * 将map集合转换为json格式的字符串
     * @param paramMap
     * @return
     */
    public static String paramsToJson(Map<String,Object> paramMap) {
        JSONObject result= new JSONObject();
        if(paramMap != null){
            Iterator<Map.Entry<String, Object>> dataIt = paramMap.entrySet().iterator();
            while(dataIt.hasNext()){
                Map.Entry<String, Object> entry = dataIt.next();
                result.accumulate(entry.getKey(), entry.getValue());
            }
        }

        return result.toString();
    }
}
